<%@ page language="java" contentType="text/html;charset=UTF-8"
	pageEncoding="utf-8"%>
<html>
<head>
	<meta charset="UTF-8">
	<title>mamadi</title>
	<link rel="stylesheet" type="text/css" href="css/common.css">
</head>
<body>
	<div class="wrapper">
		<div class="header">
			<div class="heading">
				<div class="logo">
					Hi,I am logo.<br/>
					嗨,我是麻麻的。
					
				</div>
				<div class="sertch-box">
					<input type="text" placeholder="输入关键字" />
					<span class="btn search-btn">搜索</span>
				</div>
				<div class="sertch-box">
					<select>
						<option>全部类别</option>
					</select>
				</div>
			</div>
		</div>
		<div class="content">
			<div class="list">
				<div class="row list-header">
					<div class="item">
						订单编号
					</div>
					<div class="item">
						客户编号
					</div>
					<div class="item">
						支付金额
					</div>
					<div class="item">
						购买项目
					</div>
					<div class="item">
						状态
					</div>
					<div class="item">
						操作
					</div>
				</div>
			</div>
		</div>
		<div class="footer"></div>
	</div>
</body>
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript">
	var orderArray = new Array();
	var orderLength = 0;
	if(localStorage.getItem("order") != null) {
			orderArray = JSON.parse(localStorage.getItem("order"));
			orderLength = orderArray.length;
	}
	for(var i = 0; i < orderLength; i++) {
		var s = "";
		    s += '<div class="row" style="height:auto;overflow:auto;">';
			s += '<div class="item">';
			s += orderArray[i].orderId;
			s += '</div>';
			s += '<div class="item">';
			s += orderArray[i].clientId;
			s += '</div>';
			s += '<div class="item">￥';
			s += orderArray[i].sum;
			s += '</div>';
			s += '<div class="item" style="height:auto;overflow:auto;">';
			for(var j = 0; j < orderArray[i].buyItemArray.length; j++) {
				s += '<span>' + orderArray[i].buyItemArray[j].goodName + '</span>【<span>' + orderArray[i].buyItemArray[j].countNum + '</span>】';
			}
			s += '</div>';
			s += '<div class="item">';
			s += displayStatus(orderArray[i].status);
			s += '</div>';
			s += '<div class="item">';
			s += '<select class="select-item"><option value="0">等待支付</option><option value="1">挂账记账</option><option value="2">完成支付</option></select>';
			s += '</div>';
			s += '</div>';
		$(".list").append(s);
	}

	$(document).on("change", ".select-item",function() {
		$(this).parent(".item").prev().text(displayStatus($(this).val()));
		orderArray[$(this).parents(".row").index() - 1].status = $(this).val();
		localStorage.setItem("order", JSON.stringify(orderArray));
		
		window.location.reload();
	});

	function displayStatus(status) {
		var s = "";
		switch(parseInt(status)) {
			case 0: s = "等待支付"; break;
			case 1: s = "挂账记账"; break;
			case 2: s = "完成支付"; break;
			default: s = "暂无记录";
		}
		return s;
	}
</script>
</html>